﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Allocate_Edit.aspx.cs" Inherits="page_Allocate_Edit" %>

<%@ Register Assembly="Infragistics2.WebUI.WebCombo.v7.1, Version=7.1.20071.40, Culture=neutral, PublicKeyToken=7dd5c3163f2cd0cb"
    Namespace="Infragistics.WebUI.WebCombo" TagPrefix="igcmbo" %>
<%@ Register Assembly="Infragistics2.WebUI.WebDataInput.v7.1, Version=7.1.20071.40, Culture=neutral, PublicKeyToken=7dd5c3163f2cd0cb"
    Namespace="Infragistics.WebUI.WebDataInput" TagPrefix="igtxt" %>
<%@ Register Assembly="Infragistics2.WebUI.Misc.v7.1, Version=7.1.20071.40, Culture=neutral, PublicKeyToken=7dd5c3163f2cd0cb"
    Namespace="Infragistics.WebUI.Misc" TagPrefix="igmisc" %>
<%@ Register Assembly="Infragistics2.WebUI.UltraWebGrid.v7.1, Version=7.1.20071.40, Culture=neutral, PublicKeyToken=7dd5c3163f2cd0cb"
    Namespace="Infragistics.WebUI.UltraWebGrid" TagPrefix="igtbl" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title></title>
    <link href="../style/main.css" rel="stylesheet" type="text/css" />

    <script language="javascript" type="text/javascript">

        //新增一行
        function btnAddGood_onclick() 
        {
            igtbl_addNew("UWGDetail", 0); 
            return false;
        }

        //删除一商品
        function CheckSelectRow() 
        {
            var ID = document.form1.hDetail.value;
            if(ID=="")
            {
                alert("请选择你要删除的商品！");
                return false;
            }
        }
        
        function checkPrint()
        {
            var grid=igtbl_getGridById("UWGDetail");
 
            if(grid.Rows.length==0)
            {
                alert("没有商品的单据,不能打印！");
                
                return false;
            }           
        }
    </script>

    <script id="igClientScript" type="text/javascript">

        
        //取得当前活动行
        function UWGDetail_AfterRowActivateHandler(gridName, rowId)
        {       
    	     var detailID = igtbl_getRowById(rowId).getCellFromKey("ID").getValue();     	           
             document.getElementById("hDetail").value = detailID;          
        }  
        
        //执行某行数据，增加或修改
        function UWGDetail_AfterCellUpdateHandler(gridName, cellId)
        {
            if(igtbl_getCellById(cellId).Column.Key=="GoodNo")//判断激活事件的列
            {    	        
                var goodNo = igtbl_getCellById(cellId).Row.getCellFromKey("GoodNo").getValue();     	           
      
                if(goodNo!="")
                {
                    Ajax.Good.GetGoodInfo(goodNo,GetGoodInfo_callback);
                }
            }     
        }     
        
        //回调方法，显示查出的信息
        function GetGoodInfo_callback(response)
        {
             var row=igtbl_getActiveRow("UWGDetail");   //当前行                         
             var dt = response.value;   
               
             if(dt.Rows.length>0&&dt!=null)
             { 
                 row.getCellFromKey("GoodName_CN").setValue(dt.Rows[0]["GoodName_CN"]);              
                 row.getCellFromKey("GoodNorm").setValue(dt.Rows[0]["GoodNorm"]); 
                 row.getCellFromKey("GoodColor").setValue(dt.Rows[0]["GoodColor"]); 
                 row.getCellFromKey("Price_Orig").setValue(dt.Rows[0]["Price_Orig"]);
                 row.getCellFromKey("GoodID").setValue(dt.Rows[0]["ID"]); 
             } 
             else
             {
                 row.getCellFromKey("GoodName_CN").setValue(""); 
                 row.getCellFromKey("GoodNorm").setValue(""); 
                 row.getCellFromKey("GoodColor").setValue(""); 
                 row.getCellFromKey("Price_Orig").setValue(""); 
                 row.getCellFromKey("GoodID").setValue(""); 
             } 
        }             
    
        //对数据进行校验
        function UWGDetail_AfterRowUpdateHandler(gridName, rowId)
        {
	        var Amount = igtbl_getRowById(rowId).getCellFromKey("Amount").getValue();
            
            if(Amount!=null)
            {
                for(var i=0; i<Amount.length; i++)
                {
                    if(Amount.charAt(i)<'0' || Amount.charAt(i)>'9')
                    {   
                        alert("商品数量只能是数字");
                        return false;
                    }
                }
            }
            else
            {
                alert("请填写采购数量！");
                return false;
            }
        }
</script>

</head>
<body>
    <form id="form1" runat="server">
    <br />
    <div style="text-align: center;">
        <table style="width: 96%; background-color: #85BDE2;" border="0px" cellpadding="0px"
            cellspacing="1px">
            <tr style="background-color: #DAE7F8; text-align:left" id="trOrderInfo" runat="server">
                <td>
                    订单编号：
                </td>
                <td style="width:150px">
                    <asp:DropDownList ID="ddlNO" runat="server" Width="100%">
                    </asp:DropDownList>
                </td>
                <td>
                    总 金 额：
                </td>
                <td>
                    <igtxt:WebCurrencyEdit ID="lbMoney" runat="server" ReadOnly="true" 
                        Width="116px">
                    </igtxt:WebCurrencyEdit>
                </td>
            </tr>
            <tr style="background-color: #DAE7F8;text-align:left">
                <td >
                    关联要货订单：
                </td>
                <td style="width:150px">
                    <asp:DropDownList ID="ddlInvoiceNO" runat="server" Width="100%" 
                        AutoPostBack="True" onselectedindexchanged="ddlInvoiceNO_SelectedIndexChanged">
                    </asp:DropDownList>
                </td>
                <td>
                    调拨至机构：
                </td>
                <td>
                    <asp:DropDownList ID="ddlTargetShop" runat="server" Width="110px">
                    </asp:DropDownList>
                </td>
            </tr>
            <tr style="background-color: #DAE7F8;text-align:left">
                <td style="width: 100px">
                   要货机构：
                </td>
                <td style="width: 150px">
                                        <asp:DropDownList ID="ddlSourceShop" runat="server" Width="100%" Enabled="false">
                    </asp:DropDownList>
                </td>
                <td>
                    描述：
                </td>
                <td >
                    <asp:TextBox ID="tbRemark" runat="server" Height="37px" TextMode="MultiLine" Width="242px"></asp:TextBox>
                </td>
            </tr>
            <tr style="background-color: #DAE7F8;">
                <td align="left" colspan="4">
                    &nbsp;<asp:Button ID="btnSaveMaster" runat="server" Text="保存" Height="22px" Width="90px" 
                        OnClick="btnSaveMaster_Click" />
                    &nbsp;<asp:Button ID="btnCancelMaster" runat="server" Text="取消" Height="22px" Width="90px" 
                        OnClick="btnCancelMaster_Click" />
                </td>
            </tr>
            <tr style="background-color: #DAE7F8;" id="trDetail1" runat="server">
                <td colspan="4">
                    <igtbl:UltraWebGrid ID="UWGDetail" runat="server" Style="text-align: center; top: 0px;
                        left: 0px;" Width="99%"
                        Height="208px">
                        <Bands>
                            <igtbl:UltraGridBand AllowUpdate="Yes">
                                <RowEditTemplate>
                                    <br />
                                    <p align="center">
                                        <input id="igtbl_reOkBtn" onclick="igtbl_gRowEditButtonClick(event);" style="width: 50px;"
                                            type="button" value="OK" />
                                        &nbsp;
                                        <input id="igtbl_reCancelBtn" onclick="igtbl_gRowEditButtonClick(event);" style="width: 50px;"
                                            type="button" value="Cancel" />
                                        </input> </input>
                                    </p>
                                </RowEditTemplate>
                                <AddNewRow View="NotSet" Visible="NotSet">
                                </AddNewRow>
                                <Columns>
                                    <igtbl:UltraGridColumn BaseColumnName="ID" EditorControlID="" HeaderText="ID" Key="ID"
                                        Type="Custom" Hidden="True">
                                        <Header Caption="ID">
                                        </Header>
                                    </igtbl:UltraGridColumn>
                                    <igtbl:UltraGridColumn BaseColumnName="GoodNo" HeaderText="商品编号" Key="GoodNo">
                                        <Header Caption="商品编号">
                                            <RowLayoutColumnInfo OriginX="1" />
                                        </Header>
                                        <Footer>
                                            <RowLayoutColumnInfo OriginX="1" />
                                        </Footer>
                                    </igtbl:UltraGridColumn>
                                    <igtbl:UltraGridColumn BaseColumnName="GoodName_CN" HeaderText="商品名称" Key="GoodName_CN"
                                        Type="Custom">
                                        <Header Caption="商品名称">
                                            <RowLayoutColumnInfo OriginX="2" />
                                        </Header>
                                        <Footer>
                                            <RowLayoutColumnInfo OriginX="2" />
                                        </Footer>
                                    </igtbl:UltraGridColumn>
                                    <igtbl:UltraGridColumn BaseColumnName="GoodNorm" HeaderText="商品规格" Key="GoodNorm"
                                        Type="Custom">
                                        <Header Caption="商品规格">
                                            <RowLayoutColumnInfo OriginX="3" />
                                        </Header>
                                        <Footer>
                                            <RowLayoutColumnInfo OriginX="3" />
                                        </Footer>
                                    </igtbl:UltraGridColumn>
                                    <igtbl:UltraGridColumn BaseColumnName="GoodColor" HeaderText="商品颜色" Key="GoodColor"
                                        Hidden="true" Type="Custom">
                                        <Header Caption="商品颜色">
                                            <RowLayoutColumnInfo OriginX="4" />
                                        </Header>
                                        <Footer>
                                            <RowLayoutColumnInfo OriginX="4" />
                                        </Footer>
                                    </igtbl:UltraGridColumn>
                                    <igtbl:UltraGridColumn BaseColumnName="Price_Orig" HeaderText="零售价" Key="Price_Orig"
                                        EditorControlID="WebCurrencyEdit1" Type="Custom">
                                        <Header Caption="零售价">
                                            <RowLayoutColumnInfo OriginX="5" />
                                        </Header>
                                        <Footer>
                                            <RowLayoutColumnInfo OriginX="5" />
                                        </Footer>
                                    </igtbl:UltraGridColumn>
                                    <igtbl:UltraGridColumn BaseColumnName="Amount" EditorControlID="WebNumericEdit1"
                                        HeaderText="采购数量" Key="Amount" Type="Custom">
                                        <Header Caption="采购数量">
                                            <RowLayoutColumnInfo OriginX="6" />
                                        </Header>
                                        <Footer>
                                            <RowLayoutColumnInfo OriginX="6" />
                                        </Footer>
                                    </igtbl:UltraGridColumn>
                                    <igtbl:UltraGridColumn BaseColumnName="ActualAmount" EditorControlID="WebNumericEdit1" Hidden="true"
                                        HeaderText="到货数量" Key="ActualAmount" Type="Custom">
                                        <Header Caption="到货数量">
                                            <RowLayoutColumnInfo OriginX="7" />
                                        </Header>
                                        <Footer>
                                            <RowLayoutColumnInfo OriginX="7" />
                                        </Footer>
                                    </igtbl:UltraGridColumn>
                                    <igtbl:UltraGridColumn BaseColumnName="GoodID" HeaderText="商品ID" Key="GoodID" Hidden="True">
                                        <Header Caption="商品ID">
                                            <RowLayoutColumnInfo OriginX="8" />
                                        </Header>
                                        <Footer>
                                            <RowLayoutColumnInfo OriginX="8" />
                                        </Footer>
                                    </igtbl:UltraGridColumn>
                                </Columns>
                                <RowTemplateStyle BackColor="Window" BorderColor="Window" BorderStyle="Ridge">
                                    <BorderDetails WidthBottom="3px" WidthLeft="3px" WidthRight="3px" WidthTop="3px" />
                                </RowTemplateStyle>
                            </igtbl:UltraGridBand>
                        </Bands>
                        <DisplayLayout AllowAddNewDefault="Yes" AllowColSizingDefault="Free" AllowColumnMovingDefault="OnServer"
                            AllowDeleteDefault="Yes" AllowSortingDefault="OnClient" AllowUpdateDefault="Yes"
                            BorderCollapseDefault="Separate" HeaderClickActionDefault="SortMulti" Name="UWGDetail"
                            RowHeightDefault="20px" SelectTypeRowDefault="Extended" StationaryMargins="Header"
                            StationaryMarginsOutlookGroupBy="True" TableLayout="Fixed" Version="4.00" ViewType="OutlookGroupBy"
                            AutoGenerateColumns="False">
                            <GroupByBox Hidden="True" Prompt="">
                                <Style BackColor="ActiveBorder" BorderColor="Window">
                                    </Style>
                            </GroupByBox>
                            <GroupByRowStyleDefault BackColor="Control" BorderColor="Window">
                            </GroupByRowStyleDefault>
                            <ActivationObject BorderColor="" BorderWidth="">
                            </ActivationObject>
                            <FooterStyleDefault BackColor="LightGray" BorderStyle="Solid" BorderWidth="1px">
                                <BorderDetails ColorLeft="White" ColorTop="White" WidthLeft="1px" WidthTop="1px" />
                            </FooterStyleDefault>
                            <RowStyleDefault BackColor="Window" BorderColor="Silver" BorderStyle="Solid" BorderWidth="1px"
                                Font-Names="Microsoft Sans Serif" Font-Size="8.25pt">
                                <BorderDetails ColorLeft="Window" ColorTop="Window" />
                                <Padding Left="3px" />
                            </RowStyleDefault>
                            <FilterOptionsDefault>
                                <FilterOperandDropDownStyle BackColor="White" BorderColor="Silver" BorderStyle="Solid"
                                    BorderWidth="1px" CustomRules="overflow:auto;" Font-Names="Verdana,Arial,Helvetica,sans-serif"
                                    Font-Size="11px">
                                    <Padding Left="2px" />
                                </FilterOperandDropDownStyle>
                                <FilterHighlightRowStyle BackColor="#151C55" ForeColor="White">
                                </FilterHighlightRowStyle>
                                <FilterDropDownStyle BackColor="White" BorderColor="Silver" BorderStyle="Solid" BorderWidth="1px"
                                    CustomRules="overflow:auto;" Font-Names="Verdana,Arial,Helvetica,sans-serif"
                                    Font-Size="11px" Height="300px" Width="200px">
                                    <Padding Left="2px" />
                                </FilterDropDownStyle>
                            </FilterOptionsDefault>
                            <HeaderStyleDefault BorderStyle="Solid" Height="26px" HorizontalAlign="Left">
                                <BorderDetails ColorLeft="White" ColorTop="White" WidthLeft="1px" WidthTop="1px" />
                            </HeaderStyleDefault>
                            <EditCellStyleDefault BorderStyle="None" BorderWidth="0px">
                            </EditCellStyleDefault>
                            <FrameStyle BackColor="Window" BorderStyle="Solid" BorderWidth="1px" Font-Names="Microsoft Sans Serif"
                                Font-Size="8.25pt" Height="208px" Width="99%">
                            </FrameStyle>
                            <Pager AllowCustomPaging="True" AllowPaging="True" MinimumPagesForDisplay="2" NextText="下页"
                                PrevText="上页" StyleMode="PrevNext">
                                <Style BackColor="#FFFFCC" BorderStyle="Solid" BorderWidth="1px" Height="26px">
                                    <BorderDetails ColorTop="White" WidthLeft="1px" WidthTop="1px" ColorLeft="White" > </BorderDetails ></Style>
                            </Pager>
                            <AddNewBox>
                                <Style BackColor="Window" BorderColor="InactiveCaption" BorderStyle="Solid" BorderWidth="1px">
                                    <BorderDetails ColorTop="White" WidthLeft="1px" WidthTop="1px" ColorLeft="White" > </BorderDetails ></Style>
                            </AddNewBox>
                            <ClientSideEvents AfterRowActivateHandler="UWGDetail_AfterRowActivateHandler" AfterCellUpdateHandler="UWGDetail_AfterCellUpdateHandler"
                                AfterRowUpdateHandler="UWGDetail_AfterRowUpdateHandler" />
                        </DisplayLayout>
                    </igtbl:UltraWebGrid>&nbsp;
                </td>
            </tr>
            <tr style="background-color: #DAE7F8;" id="trDetail2" runat="server">
                <td align="left" colspan="4">
                                    <asp:Button ID="btnMimeograph" runat="server" Text="打印报表" Height="22px" Width="90px" OnClick="btnMimeograph_Click"
                        OnClientClick="return checkPrint()" Visible="false"/>
                    &nbsp;<asp:Button ID="btnExporterExcel" runat="server" Text="导出Excel" Height="22px" 
                                        Width="90px" OnClick="btnExporterExcel_Click"
                      />
                    <igtxt:WebCurrencyEdit ID="WebCurrencyEdit1" runat="server">
                    </igtxt:WebCurrencyEdit>
                </td>
            </tr>
        </table>
    </div>
    <input id="hAction" runat="server" type="hidden" />
    <input id="hID" runat="server" type="hidden" />
    <input id="hDetail" runat="server" type="hidden" />
    </form>
</body>
</html>
